package com.example.performance.model;

import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.HashMap;
import java.util.Map;

/**
 * HTTP请求配置模型
 * 表示单个HTTP请求的完整配置信息
 */
public class HttpRequest {

    @JsonProperty("name")
    private String name; // 请求名称

    @JsonProperty("method")
    private String method = "GET"; // 请求方法，默认GET

    @JsonProperty("url")
    private String url; // 请求URL

    @JsonProperty("headers")
    private Map<String, String> headers = new HashMap<String, String>(); // 请求头

    @JsonProperty("body")
    private String body; // 请求体

    @JsonProperty("timeout")
    private int timeout = 30000; // 超时时间，默认30秒

    @JsonProperty("expectedStatusCode")
    private int expectedStatusCode = 200; // 期望的状态码，默认200

    @JsonProperty("description")
    private String description; // 请求描述

    // 构造函数
    public HttpRequest() {
    }

    public HttpRequest(String name, String method, String url) {
        this.name = name;
        this.method = method;
        this.url = url;
    }

    // Getter和Setter方法
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getMethod() {
        return method;
    }

    public void setMethod(String method) {
        this.method = method;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public Map<String, String> getHeaders() {
        return headers;
    }

    public void setHeaders(Map<String, String> headers) {
        this.headers = headers;
    }

    public String getBody() {
        return body;
    }

    public void setBody(String body) {
        this.body = body;
    }

    public int getTimeout() {
        return timeout;
    }

    public void setTimeout(int timeout) {
        this.timeout = timeout;
    }

    public int getExpectedStatusCode() {
        return expectedStatusCode;
    }

    public void setExpectedStatusCode(int expectedStatusCode) {
        this.expectedStatusCode = expectedStatusCode;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @Override
    public String toString() {
        return "HttpRequest{" +
                "name='" + name + '\'' +
                ", method='" + method + '\'' +
                ", url='" + url + '\'' +
                ", timeout=" + timeout +
                '}';
    }
}